/*
 * @Author: szx
 * @Date: 2021-12-26 12:56:28
 * @LastEditTime: 2021-12-26 13:10:13
 * @Description:
 * @FilePath: \leetcode\1000-1099\1078\1078.js
 */
/**
 * @param {string} text
 * @param {string} first
 * @param {string} second
 * @return {string[]}
 */
var findOcurrences = function (text, first, second) {
    const words = text.split(" ");
    const list = [];
    for (let i = 2; i < words.length; i++) {
        if (words[i - 2] === first && words[i - 1] === second) {
            list.push(words[i]);
        }
    }
    return list
};
console.log(findOcurrences('we will we will rock you', 'we', 'will'));
